package com.imyours.webservice.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.LoggerFactory;

import com.imyours.webservice.service.ServiceManager;

public class IMyoursService extends HttpServlet {
	private static ServiceManager serviceManager = new ServiceManager();

	
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String service = request.getParameter("service");
		LoggerFactory.getLogger(this.getClass()).info("incoming!");
		if (service != null && !service.isEmpty()) {
			LoggerFactory.getLogger(this.getClass()).info("call service:".concat(service));
			serviceManager.service(request, response);
		} else {
			request.getRequestDispatcher("404.jsp").forward(request, response);
		}
	}
}
